package com.inspsys.algorithms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.algorithms.domain.AlgorithmsGovern;
import com.inspsys.algorithms.service.IAlgorithmsGovernService;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 算法管理Controller
 *
 * @author inspsys
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/algorithms/govern")
public class AlgorithmsGovernController extends BaseController
{
    @Autowired
    private IAlgorithmsGovernService algorithmsGovernService;

    /**
     * 查询算法管理列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:govern:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlgorithmsGovern algorithmsGovern)
    {
        startPage();
        List<AlgorithmsGovern> list = algorithmsGovernService.selectAlgorithmsGovernList(algorithmsGovern);
        return getDataTable(list);
    }

    /**
     * 导出算法管理列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:govern:export')")
    @Log(title = "算法管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgorithmsGovern algorithmsGovern)
    {
        List<AlgorithmsGovern> list = algorithmsGovernService.selectAlgorithmsGovernList(algorithmsGovern);
        ExcelUtil<AlgorithmsGovern> util = new ExcelUtil<AlgorithmsGovern>(AlgorithmsGovern.class);
        util.exportExcel(response, list, "算法管理数据");
    }

    /**
     * 获取算法管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('algorithms:govern:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(algorithmsGovernService.selectAlgorithmsGovernById(id));
    }

    /**
     * 新增算法管理
     */
    @PreAuthorize("@ss.hasPermi('algorithms:govern:add')")
    @Log(title = "算法管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgorithmsGovern algorithmsGovern)
    {
        return toAjax(algorithmsGovernService.insertAlgorithmsGovern(algorithmsGovern));
    }

    /**
     * 修改算法管理
     */
    @PreAuthorize("@ss.hasPermi('algorithms:govern:edit')")
    @Log(title = "算法管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgorithmsGovern algorithmsGovern)
    {
        return toAjax(algorithmsGovernService.updateAlgorithmsGovern(algorithmsGovern));
    }

    /**
     * 删除算法管理
     */
    @PreAuthorize("@ss.hasPermi('algorithms:govern:remove')")
    @Log(title = "算法管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(algorithmsGovernService.deleteAlgorithmsGovernByIds(ids));
    }
}
